package com.service.impl;

import com.entity.Stores;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mapper.StoresMapper;
import com.service.IStoresService;
import com.until.ConstantUtil;
import com.vo.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class StoresServiceImpl implements IStoresService {
    @Resource
    private StoresMapper storesMapper;
    private Stores stores;

    @Override
    public PageInfo listAll(Page<Stores> page) {
      PageHelper.startPage(page.getPageNum(),page.getPageSize());
        return new PageInfo<Stores>(storesMapper.listAll(page.getData()));
    }

    @Override
    public List<Stores> listAll2() {
        Stores stores=new Stores();
        stores.setStatus(ConstantUtil.storesStatus.ENABLED);
        return storesMapper.listAll(stores);
    }

    @Override
    public Stores queryById(Integer storesId) {
        return storesMapper.queryById(storesId);
    }

    @Override
    public int insert(Stores stores) {
        return storesMapper.insert(stores);
    }

    @Override
    public int delete(Integer storesId) {
        return storesMapper.delete(storesId);
    }

    @Override
    public int update(Stores stores) {
        return storesMapper.update(stores);
    }

    @Override
    public int storesStatusUpdate(Stores stores) {
        return storesMapper.storesStatusUpdate(stores);
    }

    @Override
    public List<Stores> storesCloseQueryByParam() {
        Stores stores = new Stores();
        stores.setStatus(ConstantUtil.storesStatus.DISABLED);
        return storesMapper.storesCloseQueryByParam(stores);
    }

    @Override
    public int storesCloseUpdate(Stores stores) {
        return storesMapper.storesCloseUpdate(stores);
    }

    @Override
    public List<Stores> getStoresNameAll() {
        return storesMapper.getStoresNameAll();
    }
}
